package com.jugheadzhou.cilent1;

import com.jugheadzhou.cilent1.task.LeaderLatchTestTask;
import com.jugheadzhou.core.Base;
import com.jugheadzhou.core.zk.helper.MythServiceLeaderLatchHelper;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;

import javax.annotation.Resource;

/**
 * @author jugheadzhou
 * @date 2022-04-10
 */
@EnableScheduling
@SpringBootApplication
@ComponentScan(basePackages = Base.BASE_PACKAGE)
public class ZkClient1Application implements ApplicationRunner {

    @Resource
    private MythServiceLeaderLatchHelper mythServiceLeaderLatchHelper;

    @Resource
    private LeaderLatchTestTask leaderLatchTestTask;

    public static void main(String[] args) {
        SpringApplication.run(ZkClient1Application.class);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        mythServiceLeaderLatchHelper.start(leaderLatchTestTask);
    }
}
